<?php

/**
* Document Class
*/
class Document extends AppModel
{
	var $name = 'Document';
	
	var $belongsTo = array('Project' =>
                           array('className'  => 'Project',
                                 'conditions' => '',
                                 'order'      => '',
                                 'foreignKey' => 'project_id'
                           ),
						'Ticket' =>
                           array('className'  => 'Ticket',
                                 'conditions' => '',
                                 'order'      => '',
                                 'foreignKey' => 'ticket_id'
                           ),
						'User' =>
                           array('className'  => 'User',
                                 'conditions' => '',
                                 'order'      => '',
                                 'foreignKey' => 'user_id'
                           )
                     );
	
	public function saveContent($content)
    {
        $ret = $this->query("INSERT INTO `document_content` (`document_id`, `content`) VALUES (".$this->id.", '".mysql_escape_string($content)."')");
		return $ret;
    }
	
	public function loadContent($id)
    {
        $ret = $this->query("SELECT content FROM `document_content` WHERE document_id ='".$id."'");
		$retu = $ret[0]['document_content']['content'];
		return $retu;
    }
	
	public function deleteContent($id)
    {
        $ret = $this->query("DELETE FROM `document_content` WHERE document_id = '".$this->id."'");
    }	
}

?>